using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Framework.Library;

namespace Framework.Module.Version
{
    public class PortalVersion
    {              
        static public string AppVersionNameFromCode(long code)
        {
            string version;

            if ((code & 0xF0) > 0)
            {
                version = String.Format("{0}.{1}.{2}.{3}", (code >> 24) & 0xFF, (code >> 16) & 0xFF, (code >> 8) & 0xFF, (code >> 4) & 0x0F);
            }
            else
            {
                version = String.Format("{0}.{1}.{2}", (code >> 24) & 0xFF, (code >> 16) & 0xFF, (code >> 8) & 0xFF);
            }

            if ((code & 0x0F) > 0)
            {
                if ((code & 0x0F) == 1)
                {
                    // alpha release...
                    version += " alpha";
                }
                else if ((code & 0x0F) == 2)
                {
                    version += " beta";
                }
                else
                {
                    // Add Release Candidate
                    version += string.Format(" RC{0}", (code & 0x0F) - 2);
                }
            }

            return version;
        }
        static public string AppVersionName(string Code)
        {
            if (String.IsNullOrEmpty(Code))
            {
                return AppVersionNameFromCode(AppVersionCode);
            }
            return AppVersionNameFromCode(Convert.ToInt64(Code, 16));
        }
        static public int AppVersion
        {
            get
            {
                return 31;
            }
        }
        static public long AppVersionCode
        {
            get
            {
                return 0x01000010;
            }
        }
    }
}
